﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using WiimoteLib;
using System.Threading;

namespace Fitts__law_experiment_with_a_wiimote
{
    static class Program
    {
        private static Wiimote mote = new Wiimote();
        public static Wiimote Wiimote
        {
            get { return mote; }
        }

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
			ApplicationContext context = new ExperimentContext(true);
			Application.Run(context);
			return;
            bool showMessage = false;
            while (true)
            {
                try
                {
                    Wiimote.Connect();
                    break;
                }
                catch (Exception ex)
                {
                    showMessage = true;
                    Exception zz = ex;
                    if (MessageBox.Show("Unable to connect to the Wiimote.", "Experiment", MessageBoxButtons.RetryCancel) == DialogResult.Cancel)
                    {
                        Application.Exit();
                        return;
                    }
                    else
                    {
                        mote.Dispose();
                        mote = new Wiimote();
                    }
                }
            }
            if (showMessage)
                MessageBox.Show("Successfully connected!");
            mote.SetReportType(InputReport.IRAccel, true);
            mote.SetLEDs(true, false, false, false);
            
        }

        

        public static void showExperimentViewer()
        {
            //Thread th = new Thread(new ThreadStart(openExperimentViewerForm));
            //th.Start();
            ExperimentViewer form = new ExperimentViewer();
            form.ShowDialog();

        }
    }
}
